#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
vector<int> G[maxn];
int d[maxn];
int x = 0, num = 0x3f3f3f3f;
int N;
int dfs(int u, int fa){
    d[u] = 1;
    int t = 0;
    for(int v:G[u])if(v != fa){
        d[u] += dfs(v, u), t = max(t, d[v]);
    }
    t = max(t, N-d[u]);
    if(t < num || (t == num && u < x)) num = t, x = u;
    return d[u];
}
int main() {
    cin >> N;
    for(int i=0; i<N-1;++i){
        int a, b; cin >>a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1, 1);
    cout << x << ' ' << num << "\n";
    return 0;
}